public class ScreenServer implements Runnable{

	private java.io.OutputStream output = null;
	public ScreenServer(java.io.OutputStream out){
		this.output = out;
	}
	public void run(){
		try{
			java.awt.Dimension dimension=null;
			java.awt.image.BufferedImage bufferedImage=null;
			com.sun.image.codec.jpeg.JPEGImageEncoder encoder=null;
			while(true){
				dimension = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
				bufferedImage= (new java.awt.Robot()).createScreenCapture(new java.awt.Rectangle(0,0,(int)dimension.getWidth(),(int)dimension.getHeight()));
				javax.imageio.ImageIO.write(bufferedImage, "jpg", output);
				encoder = com.sun.image.codec.jpeg.JPEGCodec.createJPEGEncoder(output);
				encoder.encode(bufferedImage);
				output.flush();
				Thread.sleep(30);
			}
		}catch(Exception e){
			e.printStackTrace();
		}
	}
}
